#https://wiki.sipeed.com/soft/maixpy/zh/api_reference/Maix/gpio.html
import utime
from Maix import GPIO
from board import board_info
from fpioa_manager import fm
fm.register(board_info.LED_R, fm.fpioa.GPIO0)
led_pin = GPIO(GPIO.GPIO0, GPIO.OUT)
led_pin.value(1)

def irq_callback(key_boot_pin):#中断回调
    led_pin.value(not led_pin.value())


def  init_key_boot_irq():#中断初始化
    fm.register(board_info.BOOT_KEY, fm.fpioa.GPIOHS1)
    key_boot_pin = GPIO(GPIO.GPIOHS1, GPIO.IN)
    key_boot_pin.irq(trigger=GPIO.IRQ_FALLING , handler=irq_callback)#下降沿触发

def deregistration_key_boot():#取消注册
    led_b.value(1)
    fm.unregister(board_info.LED_R)
    fm.unregister(board_info.BOOT_KEY)


init_key_boot_irq()
while True:
    pass
